﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace EasyTest {

    /// <summary>
    /// RadioButton object
    /// </summary>
    public class RadioButton : IElement {

        /// <summary>
        /// Create a new RadioButton object.
        /// </summary>
        /// <param name="nameAttribute"></param>
        /// <param name="valueAttribute"></param>
        /// <param name="focus">Document container with controls to search for.</param>
        public RadioButton(string nameAttribute, string valueAttribute, Focus focus) {
            FindBy = "input[name='" + nameAttribute + "'][value='" + valueAttribute + "']";
            Focus = focus;
        }

        /// <summary>
        /// Set the focus to the container with this RadioButton and click it.
        /// </summary>
        public void Set() {
            Focus.Go();
            Action.Click(FindBy);
        }

        /// <summary>
        /// Determine whether this RadioButton is selected.
        /// </summary>
        public void VerifyIsSelected() {
            Assert.IsTrue(Action.IsSelected(FindBy));
        }

        /// <summary>
        /// Determine whether this RadioButton is NOT selected.
        /// </summary>
        public void VerifyIsNotSelected() {
            Assert.IsFalse(Action.IsSelected(FindBy));
        }
    }

}
